class ZAnimation ( object ) :
    def __init__ ( self , father , time = 0.2 , round = 0 , second = 22 / 1000.00 ) :
        self._running = True
        self.showInfo = False
        self.imageMaster = [ ]
        self.currentTime = 0
        self.time = time
        self.round = 0
        self.index = 0
        self.roundOver = round
        self.second = second
        self.rect = father.rect

    def load ( self , images ) :
        self.imageMaster = images

    def draw ( self ) :
        if self._running :
            if len ( self.imageMaster ) :
                self.currentTime += self.second
                if self.roundOver :
                    if self.round < self.roundOver :
                        if self.currentTime >= self.time :
                            if self.index < len ( self.imageMaster ) - 1 :
                                self.index += 1
                                self.currentTime = 0
                            else :
                                self.index = 0
                                self.currentTime = 0
                                self.round += 1
                        return self.index
                    else :
                        self.currentTime = self.index = self.round = 0
                        self._running = False
                else :
                    if self.currentTime >= self.time :
                        if self.index < len ( self.imageMaster ) - 1 :
                            self.index += 1
                            self.currentTime = 0
                        else :
                            self.index = 0
                            self.currentTime = 0
                            self.round += 1
            return self.index

        if self.showInfo :
            print self.currentTime , self.index , self.round , self.roundOver

    def play ( self ) :
        self._running = True

    def stop ( self ) :
        self._running = False

    def remove ( self ) :
        self._running = False
        self.imageMaster = [ ]

    def clear ( self ) :
        self.imageMaster = [ ]

    def printInfo ( self , value = True ) :
        self.showInfo = value
